package router

import (
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"

	"admin-nexus-backend/internal/handler"
	"admin-nexus-backend/internal/service"
)

// SetupResourceRoutes 设置资源管理路由
func SetupResourceRoutes(router *gin.RouterGroup, db *gorm.DB) {
	// 创建服务实例
	resourceService := service.NewResourceService(db)
	resourceHandler := handler.NewResourceHandler(resourceService)

	// 资源管理路由组
	resourceRoutes := router.Group("/resources")
	{
		// 获取资源列表
		resourceRoutes.GET("", resourceHandler.GetResourceList)
		// 获取资源树
		resourceRoutes.GET("/tree", resourceHandler.GetResourceTree)
		// 根据ID获取资源信息
		resourceRoutes.GET("/:id", resourceHandler.GetResourceByID)
		// 创建资源
		resourceRoutes.POST("", resourceHandler.CreateResource)
		// 更新资源
		resourceRoutes.PUT("/:id", resourceHandler.UpdateResource)
		// 删除资源
		resourceRoutes.DELETE("/:id", resourceHandler.DeleteResource)
		// 批量删除资源
		resourceRoutes.DELETE("/batch", resourceHandler.BatchDeleteResource)
	}
}
